/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DTO;

/**
 *
 * @author 10520_000
 */
public class Sach implements Idata
{
    private String MaSach = "";
    public String TenSach = "";
    public String TheLoai = "";
    public String TacGia = "";
    public int SoLuongTon = -1;
    public int SoLuongTon2 = -1;
    public String type = "OR";
    public Sach(String ...param)
    {
        try
        {
            MaSach = param[0];
            
            TenSach = param[1];
            TheLoai = param[2];
            TacGia = param[3];
            SoLuongTon = Integer.parseInt(param[4]);
            if(param.length == 7)
            {
                SoLuongTon2 = Integer.parseInt(param[5]);
                type = param[6];
            }
            else
                if( param.length == 6)
                {
                    SoLuongTon2 = SoLuongTon;
                    type = param[5];
                }
        }
        catch(NumberFormatException iex)
        {
            SoLuongTon = SoLuongTon2 = -1;
        }
        catch(Exception ex)
        {
            
        }
    }

    @Override
    public boolean Delete() 
    {
        return new BUS.Sach().Delete(this);
    }

    @Override
    public boolean Insert() 
    {
        return new BUS.Sach().Insert(this);
    }

    @Override
    public boolean Update() 
    {
        return new  BUS.Sach().Update(this);
    }

    @Override
    public Object[] getObjects() 
    {
        return new Object[] 
        {
            MaSach, TenSach, TheLoai, TacGia, SoLuongTon
        };
    }
    @Override
    public String getID() 
    {
        return MaSach;
    }
    
    
    
}
